#include <bits/stdc++.h>
using namespace std;
const int N = 205;
int win[5][5] = {
    {0, -1, 1, 1, -1},
    {1, 0, -1, 1, -1},
    {-1, 1, 0, -1, 1},
    {-1, -1, 1, 0, 1},
    {1, 1, -1, -1, 0},
};
int sum1, sum2;
int a[N], b[N];
int n;
int main()
{
    scanf("%d%d%d", &n, &sum1, &sum2);
    for (int i = 0; i < sum1; i++)
    {
        scanf("%d", &a[i]);
    }
    for (int i = 0; i < sum2; i++)
    {
        scanf("%d", &b[i]);
    }
    int p1 = 0, p2 = 0;
    int s1 = 0, s2 = 0;
    for (int i = 0; i < n; i++)
    {
        if (win[a[p1]][b[p2]] == 1)
        {
            s1++;
        }
        else if (win[a[p1]][b[p2]] == -1)
        {
            s2++;
        }
        p1 = (p1 + 1) % sum1;
        p2 = (p2 + 1) % sum2;
    }
    printf("%d %d", s1, s2);
    return 0;
}